package com.zmn.mcc.admin.controller.staff;

import com.zmn.mcc.admin.controller.MccBaseController;
import com.zmn.mcc.business.interfaces.dept.DeptBService;
import com.zmn.mcc.business.interfaces.organize.OrganizeBService;
import com.zmn.mcc.business.interfaces.staff.StaffBService;
import com.zmn.mcc.business.interfaces.staff.ip.StaffIpInfoBService;
import com.zmn.mcc.services.interfaces.dept.DeptService;
import com.zmn.mcc.services.interfaces.organize.OrganizeService;
import com.zmn.mcc.services.interfaces.role.RoleService;
import com.zmn.mcc.services.interfaces.staff.StaffService;

import javax.annotation.Resource;
import java.util.Calendar;
import java.util.Date;

/**
 * @author heguanghua
 * @since 2020/04/15 10:24
 */
public class StaffBaseController extends MccBaseController {

    @Resource
    protected StaffService staffService;
    @Resource
    protected StaffBService staffBService;
    @Resource
    protected DeptService deptService;
    @Resource
    protected DeptBService deptBService;
    @Resource
    protected OrganizeService organizeService;
    @Resource
    protected OrganizeBService organizeBService;
    //    @Resource
//    protected EsStaffService esStaffService;
    @Resource
    protected RoleService roleService;

    String calcLengthOfService(Date date) {
        if (date == null) {
            return "";
        }

        Calendar cal = Calendar.getInstance();
        cal.set(Calendar.HOUR_OF_DAY, 0);
        cal.set(Calendar.MINUTE, 0);
        cal.set(Calendar.SECOND, 0);
        cal.set(Calendar.MILLISECOND, 0);

        Calendar setCal = Calendar.getInstance();
        setCal.setTime(date);
        setCal.set(Calendar.HOUR_OF_DAY, 0);
        setCal.set(Calendar.MINUTE, 0);
        setCal.set(Calendar.SECOND, 0);
        setCal.set(Calendar.MILLISECOND, 0);
        long yearToMilliSecond = (long)1000*60*60*24*365;
        long yearDiff =(cal.getTimeInMillis()-setCal.getTimeInMillis())/(yearToMilliSecond);

        if (yearDiff <= 0) {
            return "不足一年";
        } else {
            return yearDiff + "年";
        }
    }

}
